<template>
  <div>
    <el-card>
      <!-- 搜索栏 -->
      <el-input placeholder="请输入内容" class="input-with-select" style="width: 300px" v-model="query.query">
        <el-button slot="append" icon="el-icon-search" @click="getlist"></el-button>
      </el-input>
      <!-- 主体内容 -->
      <el-table :data="tableData" border style="width: 100%">
        <el-table-column type="index" label="#"></el-table-column>
        <el-table-column prop="order_number" label="订单编号"></el-table-column>
        <el-table-column prop="order_price" label="订单价格"> </el-table-column>
        <el-table-column prop="order_pay" label="是否付款">
          <template slot-scope="scope">
            <el-tag type="success" v-if="scope.row.order_pay==1">已付款</el-tag>
            <el-tag type="danger" v-if="scope.row.order_pay==0">未付款</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="is_send" label="是否发货"></el-table-column>
        <el-table-column prop="create_time" label="下单时间">
            <template slot-scope="scope">
                {{scope.row.create_time|times}}
            </template>
        </el-table-column>
        <el-table-column label="操作">
            <template slot-scope="scope">
                 <el-button type="primary" icon="el-icon-edit" circle @click="edit(scope.row.id)"></el-button>
                 <el-button type="success" icon="el-icon-location-information" circle @click="list(scope.row.order_id)"></el-button>
            </template>
        </el-table-column>
      </el-table>
      <!-- 分页 -->
      <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="query.pagenum"
      :page-sizes="[1,3,5,7]"
      :page-size="100"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total">
    </el-pagination>
    <!--修改地址 -->
    <el-dialog title="修改地址" :visible.sync="dialogFormVisible">
      <el-form>
        <el-form-item label="省市区/县" label-width="80px">
             <el-cascader v-model="value"></el-cascader>
        </el-form-item>
        <el-form-item label="详细地址" label-width="80px">
          <el-input v-model="input"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary">确 定</el-button>
      </div>
    </el-dialog>
    <!-- 物流信息 -->
    <el-dialog title="物流信息" :visible.sync="dialogFormVisible1">
      <el-form>
          <el-timeline>
    <el-timeline-item v-for="(item,index) in wlxx" :key="index" >
      {{item.context}}
    </el-timeline-item>
  </el-timeline>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible1 = false" type="primary">关闭</el-button>
      </div>
    </el-dialog>
    </el-card>
  </div>
</template>
<script>
import qs from "querystring";
import moment from 'moment'
import city from '@/assets/city_data2017_element'
export default {
  data() {
    return {
        tableData:[],
        // 参数
        query:{
            query:'',
            pagenum:1,
            pagesize:5,
            user_id:"",
            pay_status:"",
            is_send:'',
            order_fapiao_title:'',
            order_fapiao_company:'',
            order_fapiao_content:'',
            consignee_addr:''
        },
        // 总条数
        total:0,
        // 控制对话框开关
        dialogFormVisible:false,
        dialogFormVisible1:false,
        // 物流信息
        wlxx:[],
        val:city,
        input:'',
        value:''
    };
  },
  methods: {
    // 主体渲染
    async getlist(){
          let { data: res } = await this.$http.get(
        "orders/" + "?" + qs.stringify(this.query)
      );
        this.tableData=res.data.goods
        this.total=res.data.total
    },
    // 条数
    handleSizeChange(val){
        this.query.pagesize=val
        this.getlist()
    },
    // 页数
    handleCurrentChange(val){
        this.query.pagenum=val
        this.getlist()
    },
    // 修改对话框打开
    edit(){
      this.dialogFormVisible=true
    },
    // 物流信息
    async list(id){
      this.dialogFormVisible1=true
      let {data}=await  this.$http.get('/kuaidi/'+id)
      this.wlxx=data.data 
    },
    
  },
  // 时间转换
  filters:{
    times(val){
        return moment(val).format('YYYY/MM/DD hh:mm:ss')
    }
  },
  // 调有渲染
  mounted() {
    this.getlist()
  },

 
};
</script>

<style lang="scss" scoped>
.input-with-select{
    margin-bottom: 20px;
}
</style>